/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package rukopisyimport.cli;

import java.util.Properties;
import rukopisyimport.ManuscriptCollection;
import rukopisyimport.sourceData.SourceDocumentsManager;

/**
 *
 * @author Martin Řehánek (rehan at mzk.cz)
 */
public class UpdateMarcRecordsForDigitizedTeisAction implements Action {

    private static final boolean REWRITE_PRESENT_RECORDS = true;
    private final ManuscriptCollection col;
    private final Properties properties;

    public UpdateMarcRecordsForDigitizedTeisAction(ManuscriptCollection col, Properties properties) {
        this.col = col;
        this.properties = properties;
    }

    public ActionResult run(ActionResult previousActionResult) {
        try {
            SourceDocumentsManager manager = new SourceDocumentsManager(col.getDir(), properties);
            manager.downloadMarcRecordsForDigitalizedTeis(REWRITE_PRESENT_RECORDS);
        } catch (Throwable e) {
            e.printStackTrace();
            return new ActionResult(false, previousActionResult.getResultData());
        }
        return new ActionResult(true, previousActionResult.getResultData());
    }
}
